package com.ridanlabs.onelist.db;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.json.JSONObject;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class ItemModel implements Comparable<ItemModel> {
	public ItemModel(String itemName, int quantity) {
		this.listItemName = itemName;
		this.quantity = quantity;
	}
	
	public void setCheckedTo(boolean val) {
		if(val)
			this.checked = 1;
		this.checked = 0;
	}

	public String getItemName() {
		return this.listItemName;
	}

	public boolean isChecked() {
		if(checked == 0 )
			return false;
		return true;
	}
	
	public int getQuantity() {
		return this.quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	
	public Key getKey() {
		return this.key;
	}
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String listItemName;
	
	@Persistent
	private Integer checked = new Integer(0);
	
	@Persistent
	private int quantity;

	@Override
	public int compareTo(ItemModel o) {
		return listItemName.compareTo(o.listItemName);
	}
}
